/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.rational.sheet.table.column;

import javax.swing.JTable;


/**
 *
 * @author Overmind
 */
public class ColumnHeaderAdapter
{
    private JTable table = null;
    private ColumnHeaderRenderer headerRenderer = null;
    private ColumnHeaderMouseAddapter mouseAddapter = null;
    
    public ColumnHeaderAdapter()
    {

    }
    
    public ColumnHeaderAdapter(JTable table)
    {
	setTable(table);
    }
    
    public JTable getTable()
    {
	return table;
    }
    
    public ColumnHeaderRenderer getHeaderRenderer()
    {
	return headerRenderer;
    }
    
    public ColumnHeaderMouseAddapter getMouseAddapter()
    {
	return mouseAddapter;
    }
    
    public final void setTable(JTable table)
    {
	this.table = table;
	
	headerRenderer = new ColumnHeaderRenderer();
	mouseAddapter = new ColumnHeaderMouseAddapter();
	
	if(table != null)
	{
	    table.getTableHeader().addMouseListener(mouseAddapter);
	    table.getTableHeader().setDefaultRenderer(headerRenderer);
	}
    }
}
